<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%option explicit%>
<%
Dim RZ_IN
RZ_IN=1
%>
<!--#include file="../conn.inc.asp" -->
<!--#include file="admin_inc/admin.function.asp" -->
<!--#include file="admin_inc/admin.sqlfunction.asp" -->

<%
'作者：山林客（ah_bill）
'博客：http://ruizhinet.blog.163.com
'网站：http://www.ruizhinet.cn
'本信息不会影响您网站的正常访问，请保留
checkadmin(4)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>更新</title>
<link type="text/css" href="style/style.css" rel="stylesheet" rev="stylesheet"/>
<script type="text/javascript" src="admin_js/dateselect.js"></script>
<script type="text/javascript" src="admin_js/common.js"></script>
</head>
<body>
<%
Dim result,act,sessionsql
result=""
act=Trim(request.form("act"))
If act="go" Then 
Call Process()
Else 
Call Default()
End If 

Function ExecSQL(sql)
	On Error Resume Next
	result=result&"<li>执行语句："&sql
	conn.execute(sql)
	if Err.Number<>0 Then
		result=result&"<span style='color:red;'>失败</span>"
	Else
		result=result&"成功"
	end If
	result=result&"</li>"
End Function 
%>

<%Sub Default()%>
<form name="rzform" method="post" action="?st=1" onsubmit="return isNotEmpty('sqlcontent','SQL语句');">
<input type="hidden" name="act" id="act" value="go"/>
<table class="table_800" cellspacing="0" cellpadding="0">
<tr><th>瑞志企业建站系统数据库升级工具</th></tr>
<tr><td>
<span style="color:red;">警告：在升级之前请务必备份原数据库！<a href="manage_database.asp"><span style="color:blue;">点击这里备份</span></a></span>
</td></tr>
<tr><td><span style="color:red;">每条SQL语句必须写在同一行上，以换行符（回车符）分隔。</span></td></tr>
<tr><td>
<textarea id="sqlcontent" name="sqlcontent" rows="20" cols="100" style="word-wrap:normal;overflow:auto;"></textarea>
</td></tr>
<tr><td class="tdcenter">
<input type="submit" class="btn" value="升级数据库"/>
</td></tr>
</table>
</form>
<%End Sub%>
<%
Sub Process()
Dim sqlcontent
sqlcontent=Trim(request.Form("sqlcontent"))
If(sqlcontent<>"") Then 
	Dim sqlarr,i
	sqlarr=Split(sqlcontent,Chr(10))
	For i=0 To UBound(sqlarr)
		If Trim(sqlarr(i))<>"" And Len(sqlarr(i))>10 Then 
			On Error Resume Next
			conn.Execute(sqlarr(i))
			if Err.Number<>0 Then
				Dim errdesc
				errdesc=Err.Description
				Err.Clear
				result=result&"<li><span style='color:red;'>"&REPLACE(sqlarr(i),"<","&lt;")&"<br/>&nbsp;&nbsp;——执行失败，错误原因："&errdesc&"</span></li>"
			Else
				result=result&"<li><span style='color:blue;'>"&REPLACE(sqlarr(i),"<","&lt;")&"<br/>&nbsp;&nbsp;——执行成功</span></li>"
			End If 
		End If 
	Next 
	Call SetSiteConfig()
	Call SetSiteWords()
	Call SetTypeProperties()
Else
	result="<li>请将sql.txt中的内容粘贴后再执行此步骤，<a href='update.asp'>点此返回</a></li>"
End If 
%>
<table class="table_800" cellspacing="0" cellpadding="0">
<tr><th>升级数据库运行结果</th></tr>
<tr><td>
<ol>
<%=result%>
</ol>
</td></tr>
</table>
<%End Sub%>
</body>
</html>

